package com.lims.landInfo.dao;


import javacommon.base.*;

import cn.org.rapid_framework.page.*;

import com.lims.landInfo.model.*;
import com.lims.landInfo.vo.query.*;

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;
/**
 * @author zzh
 * @version 1.0
 * @since 1.0
 */
@Repository @SuppressWarnings("unchecked")
public class CorpaffDao extends BaseHibernateDao<Corpaff,java.lang.String>{

	
	public Class getEntityClass() {
		return Corpaff.class;
	}
	
	public Page findPage(CorpaffQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from Corpaff t where 1=1 "
			  	+ "/~ and t.sno = {sno} ~/"
			  	+ "/~ and t.corpno = {corpno} ~/"
			  	+ "/~ and t.name = {name} ~/"
			  	+ "/~ and t.parentno = {parentno} ~/"
			  	+ "/~ and t.parentname = {parentname} ~/"
			  	+ "/~ and t.treeno = {treeno} ~/"
			  	+ " order by t.sno asc ";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from Corpaff t where 1=1 ");
        if(isNotEmpty(query.getObjid())) {
            sql2.append(" and  t.objid = :objid ");
        }
        if(isNotEmpty(query.getSno())) {
            sql2.append(" and  t.sno = :sno ");
        }
        if(isNotEmpty(query.getCorpno())) {
            sql2.append(" and  t.corpno = :corpno ");
        }
        if(isNotEmpty(query.getName())) {
            sql2.append(" and  t.name = :name ");
        }
        if(isNotEmpty(query.getParentno())) {
            sql2.append(" and  t.parentno = :parentno ");
        }
        if(isNotEmpty(query.getParentname())) {
            sql2.append(" and  t.parentname = :parentname ");
        }
        if(isNotEmpty(query.getTreeno())) {
            sql2.append(" and  t.treeno = :treeno ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	

}
